package com.example.jbmsuppliers.sinopec.activity;

import android.app.Activity;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.view.View;

import com.example.jbmsuppliers.sinopec.utlis.ExitAppUtlis;
import com.example.jbmsuppliers.sinopec.view.DoubleButtonDialog;

/**
 * Created by 李征 on 2017/3/11.
 */

public class OvertActivity extends Activity {
    //判断网络是否链接
    public int  setConnectivityManager(){
        ConnectivityManager connectivityManager= (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
        NetworkInfo info = connectivityManager.getActiveNetworkInfo();
        if (info==null){
            return 0;
        }else{
            return 1;
        }

    }
   //一些提示的时候调用
    public void hint(String name) {
        final DoubleButtonDialog dialog = new DoubleButtonDialog(
                OvertActivity.this, name);
        dialog.getokbtn().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();

            }
        });
        dialog.setisVisibility();

    }
    //用户退出时使用
    public  void exit(String name) {
        final DoubleButtonDialog dialog = new DoubleButtonDialog(
                OvertActivity.this, name);
        dialog.getokbtn().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
                ExitAppUtlis.getInstance().exit();
            }
        });
        dialog.getnobtn().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

    }

    //来获取用户的Login_id
    public String GainLoginID(String key){
        SharedPreferences sharedPreferences=getSharedPreferences("Anime_Login_id",MODE_PRIVATE);
        String string=sharedPreferences.getString(key,"");
        return string;
    }
}
